package demo1;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: liangyuanzhang
 * Date: 2025-3-12
 * Time: 17:33
 */
// 移除元素
class Solution{
    public int removeElement(int[] nums,int val){
        int cur = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != val){
                nums[cur++] = nums[i];
            }
        }
        return cur;
    }
}
public class Test {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] array = {3,2,2,3};
        int ret = solution.removeElement(array,3);
        int[] arr = Arrays.copyOf(array,ret);
        System.out.println(Arrays.toString(arr));
    }
}
